<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>常量编辑</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link rel="stylesheet" href="/static/layui/css/layui.css" />
<link rel="stylesheet" href="/static/ui/css/ui.css" />

    </head>
    <body>
        <form class="layui-form" action="" lay-filter="editform">
            <div class="mainBox">
                <div class="main-container">
                    <div class="main-container">
                        <div class="layui-form-item">
                            <label class="layui-form-label">常量名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入常量名称" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">常量标志</label>
                            <div class="layui-input-block">
                                <input type="text" name="key" lay-verify="required" autocomplete="off" placeholder="请输入常量标志" class="layui-input">
                                <div class="layui-form-mid layui-word-aux">不能和系统中的其他常量标志相同</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">常量类型</label>
                            <div class="layui-input-block">
                                <input type="radio" value="1" name="type" title="文件" checked class="modck">
                                <input type="radio" value="2" name="type" title="数字">
                                <input type="radio" value="3" name="type" title="字符串"><br>
                                <input type="radio" value="4" name="type" title="数组">
                                <input type="radio" value="5" name="type" title="对象">
                            </div>
                        </div>
                        
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">常量内容</label>
                            <div class="layui-input-block">
                                <textarea name="content" placeholder="常量内容" class="layui-textarea" lay-verify="required"></textarea>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <div class="bottom">
                <div class="button-container">
                    <input type="hidden" name="id" value="0" id="id">
                    <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="user-save">
                        <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
                </div>
            </div>
        </form>
        <script src="../config.js"></script>
        <script src="/static/layui/layui.js"></script>
		<script src="/static/ui/ui.js"></script>
        <script>
            layui.use([
                'form', 'layer'
            ], function () {
                let form = layui.form,
                    layer = layui.layer,
                    $ = layui.$,
                    req = _req();
                if(req.id){
                    _get(layui, 'mod/paramsBefore?id=' + req.id, res => {
                        form.val('editform', res)
                    });
                }
                
                
                //监听提交
                    form.on('submit(user-save)', function (data) {
                        data = data.field;
                        let postUrl = data.id > 0 ? 'mod/paramsEdit' : 'mod/paramsAdd';
                        _post(layui, postUrl, data, rt => {
                            parent
                                .layui
                                .table
                                .reload("param-table");
                            parent
                                .layer
                                .close(parent.layer.getFrameIndex(window.name)); //关闭当前页

                        })

                        return false;
                    });

            });
        </script>

    </body>
</html>